import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    BASE_URL: process.env.BASE_URL,
    currentGoods: {},
    token: '',
    openid: '',
    exclude: []
  },
  mutations: {
    token(state, token) {
      state.token = token
    },
    addNoCache(state, name) {
      let index = state.exclude.indexOf(name)
      if (index < 0) {
        state.exclude.push(name)
      }
    },
    removeNoCache(state, name) {
      let index = state.exclude.indexOf(name)
      state.exclude.splice(index, 1)
    },
    serCurrentGoods(state, currentGoods) {
      state.currentGoods = currentGoods
    }
  },
  actions: {
  }
})
